from Mouth_examofzhuan5.Base.Base import Base
from time import sleep
from selenium.webdriver.common.by import By

class Page_one(Base):
    # 点击去登录  classname
    go_login=(By.CLASS_NAME,'headerLogin')

    # 输入用户名  id属性
    login1=(By.ID,'userName')
    # 输入密码 name属性
    login2=(By.NAME,'_pwd')
    # 点击登录 name属性
    login_btn=(By.NAME,'bi_Usuallogin')

    # 登录成功断言
    login_s=(By.XPATH,'/html/body/div[2]/div/div[1]/div/p/span')

    # xpath绝对路径 xpath高级2
    login_sure=(By.XPATH,'/html/body/div/div[4]/div[2]/div[2]/a')

    # 搜索框  cssselector属性
    search=(By.CSS_SELECTOR,'.search-form')


    # 商品图片
    sp_pict=(By.XPATH,'/html/body/div[6]/div/div[2]/div[5]/ul/li[1]/div[2]/div[1]/a/img')

    # 加入购物车 xpath高级3
    add_car=(By.ID,'addToCartForDetail')
    # 业务逻辑
    def sp_addcar(self,username,password):
        self.click(self.go_login)
        self.send_keys(self.login1,username)
        self.send_keys(self.login2,password)
        # 强制等待10秒 输入验证码
        sleep(10)
        self.click(self.login_btn)
        self.click(self.login_sure)
        text=self.get_text(self.login_s)
        self.send_keys(self.search,'赖茅')
        self.enter(self.search)
        self.click(self.sp_pict)
        self.new_window()
        self.click(self.add_car)
        return text


    def fanli(self,username,password):
        self.click(self.go_login)
        self.send_keys(self.login1, username)
        self.send_keys(self.login2, password)
        # 强制等待10秒 输入验证码
        sleep(10)
        self.click(self.login_btn)








